package br.inatel.ec203.projeto.view;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class OtherComponentSpecificPanel extends JPanel {

	private static final long serialVersionUID = 543125612168161160L;

	private JLabel kindLabel;
	private JTextField kindTextField;
	private JLabel informationLabel;
	private JTextField informationTextField;
	
	private GridBagConstraints kindLabelConstraints;
	private GridBagConstraints kindTextFieldConstraints;
	private GridBagConstraints informationLabelConstraints;
	private GridBagConstraints informationTextFieldConstraints;
	
	public OtherComponentSpecificPanel() {
		setLayout(new GridBagLayout());
		add(getKindLabel(), getKindLabelConstraints());
		add(getKindTextField(), getKindTextFieldConstraints());
		add(getInformationLabel(), getInformationLabelConstraints());
		add(getInformationTextField(), getInformationTextFieldConstraints());
	}

	public JLabel getKindLabel() {
		if (kindLabel == null) {
			kindLabel = new JLabel();
			kindLabel.setText("Tipo");
		}
		return kindLabel;
	}

	public JTextField getKindTextField() {
		if (kindTextField == null) {
			kindTextField = new JTextField();
		}
		return kindTextField;
	}

	public JLabel getInformationLabel() {
		if (informationLabel == null) {
			informationLabel = new JLabel();
			informationLabel.setText("Informacoes");
		}
		return informationLabel;
	}

	public JTextField getInformationTextField() {
		if (informationTextField == null) {
			informationTextField = new JTextField();
		}
		return informationTextField;
	}

	private GridBagConstraints getKindLabelConstraints() {
		if (kindLabelConstraints == null) {
			kindLabelConstraints = new GridBagConstraints();
			kindLabelConstraints.gridx = 0;
			kindLabelConstraints.gridy = 0;
			kindLabelConstraints.anchor = GridBagConstraints.LINE_START;
			kindLabelConstraints.insets = new Insets(5, 5, 5, 5);
		}
		return kindLabelConstraints;
	}

	@SuppressWarnings("static-access")
	private GridBagConstraints getKindTextFieldConstraints() {
		if (kindTextFieldConstraints == null) {
			kindTextFieldConstraints = new GridBagConstraints();
			kindTextFieldConstraints.gridx = 1;
			kindTextFieldConstraints.gridy = 0;
			kindTextFieldConstraints.ipadx = 360;
			kindTextFieldConstraints.fill = new GridBagConstraints().HORIZONTAL;
			kindTextFieldConstraints.insets = new Insets(5, 5, 5, 5);
		}
		return kindTextFieldConstraints;
	}

	private GridBagConstraints getInformationLabelConstraints() {
		if (informationLabelConstraints == null) {
			informationLabelConstraints = new GridBagConstraints();
			informationLabelConstraints.gridx = 0;
			informationLabelConstraints.gridy = 1;
			informationLabelConstraints.anchor = GridBagConstraints.LINE_START;
			informationLabelConstraints.insets = new Insets(5, 5, 5, 5);
		}
		return informationLabelConstraints;
	}

	@SuppressWarnings("static-access")
	private GridBagConstraints getInformationTextFieldConstraints() {
		if (informationTextFieldConstraints == null) {
			informationTextFieldConstraints = new GridBagConstraints();
			informationTextFieldConstraints.gridx = 1;
			informationTextFieldConstraints.gridy = 1;
			informationTextFieldConstraints.ipadx = 360;
			informationTextFieldConstraints.fill = new GridBagConstraints().HORIZONTAL;
			informationTextFieldConstraints.insets = new Insets(5, 5, 5, 5);
		}
		return informationTextFieldConstraints;
	}
	
	public ArrayList<String> getData(){
		ArrayList<String> data = new ArrayList<String>();
		
		data.add(Util.addInArrayList(getKindTextField().getText()));
		data.add(Util.addInArrayList(getInformationTextField().getText()));
		
		return data;
	}

}














